//
//  UIView+Extension.h
//  DGGUIKit
//
//  Created by dgg_hzk on 2019/11/21.
//

#import <UIKit/UIKit.h>

typedef void (^DLGestureActionBlock)(UIGestureRecognizer *gestureRecoginzer);

@interface UIView (Extension)

@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;
@property (nonatomic, assign) CGFloat width;
@property (nonatomic, assign) CGFloat height;
@property (nonatomic, assign) CGSize size;
@property (nonatomic, assign) CGFloat top;
@property (nonatomic, assign) CGFloat bottom;
@property (nonatomic, assign) CGFloat left;
@property (nonatomic, assign) CGFloat right;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
/**
 获取window最上面的View

 @return view
 */
+ (UIView *)topView;

/**
 view截图
 
 @return view的截图
 */
- (UIImage *)screenshot;
/**
  获取指定视图在window中的位置

 
 @return 坐标
 */
- (CGRect)getFrameInWindow;
/**
 *  @target  target
 *
 *  @param action 方法名
 */
-(void)addTapWithTarget:(id)target action:(SEL)action;
/**
 *  @brief  添加tap手势
 *
 *  @param block 代码块
 */
- (void)addTapActionWithBlock:(DLGestureActionBlock)block;
/**
 *  @brief  添加长按手势
 *
 *  @param block 代码块
 */
- (void)addLongPressActionWithBlock:(DLGestureActionBlock)block;

/**
 把多个view横向加载到view上 并且添加约束 各个view的距离是一样的

 @param views view的数组
 */
- (void)distributeSpacingHorizontallyWith:(NSArray*)views;

/**
 把多个view竖向加载到view上 并且添加约束 各个view的距离是一样的
 
 @param views view的数组
 */
- (void) distributeSpacingVerticallyWith:(NSArray*)views;

-(void)drawRound:(CGFloat)cornerRadius RectCorners:(UIRectCorner)rectCorner;

/**  设置圆角  */
- (void)rounded:(CGFloat)cornerRadius;

/**  设置圆角和边框  */
- (void)rounded:(CGFloat)cornerRadius width:(CGFloat)borderWidth color:(UIColor *)borderColor;

/**  设置边框  */
- (void)border:(CGFloat)borderWidth color:(UIColor *)borderColor;

/**   给哪几个角设置圆角  */
-(void)round:(CGFloat)cornerRadius RectCorners:(UIRectCorner)rectCorner;

/**  设置阴影  */
-(void)shadow:(UIColor *)shadowColor opacity:(CGFloat)opacity radius:(CGFloat)radius offset:(CGSize)offset;

/**
 获取view所在viewController

 @return view所在viewController
 */
- (UIViewController *)viewController;

/**
 获取view所在navigationController

 @return view所在navigationController
 */
- (UINavigationController *)navigationController;

+ (CGFloat)getLabelHeightByWidth:(CGFloat)width Title:(NSString *)title font:(UIFont *)font;

+ (instancetype)viewFromXib;

@end
